#include "lib.h"
#include "vpconn.h"
#include "vpguts.h"
#include "vphand.h"

void
handtest(uint8* msg, VPConnection* conn)
{
	switch (msg[0])
	{
		case 't':	// test hand for a particular game
		{
			uint8 machId;
			VPGuts* guts;

			machId = msg[1];
			
			guts = VPGuts::getGuts(machId, 0);
			if (guts)
			{
				VPHand hand(guts->getCardMgr());
				int32 evt;

				hand.add(msg[2]);
				hand.add(msg[3]);
				hand.add(msg[4]);
				hand.add(msg[5]);
				hand.add(msg[6]);

				guts->CalcPayout(&evt, &hand, 5, VPGuts::DRAWN_CARDS, 0, 0);

				conn->msgStart();
				conn->msgAdd((uint8)'t');
				conn->msgAdd((uint8)(evt & 0xff));
				conn->msgEnd();
			}
			else
			{
				conn->msgStart();
				conn->msgAdd((uint8)'E');
				conn->msgEnd();
			}
			break;
		}
	}
}
